/*     */ package com.yc.dao.station;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.PowerBoxBO;
/*     */ import com.yc.util.FormateSQL;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class PowerBoxDAO
/*     */ {
/*  21 */   private static final Log log = LogFactory.getLog(PowerBoxDAO.class);
/*     */ 
/*  23 */   private dbConnector dbcon = null;
/*  24 */   private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*     */ 
/*     */   private void dbConInit() {
/*  27 */     if (this.dbcon == null)
/*  28 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   private void dbConClose() {
/*  32 */     if (this.dbcon != null)
/*  33 */       this.dbcon.closeAll();
/*  34 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getPowerBoxList(Map condition)
/*     */   {
/*  39 */     ListContentsBFO bfo = new ListContentsBFO();
/*  40 */     int start = Integer.parseInt(condition.get("start").toString());
/*  41 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  42 */     String strBtscode = condition.get("BTS_CODE").toString();
/*  43 */     ResultSet rs = null;
/*  44 */     List list = new ArrayList();
/*     */     try
/*     */     {
/*  47 */       dbConInit();
/*  48 */       String strSQL = " select count(id) from powerbox where btscode = '" + strBtscode + "' ";
/*  49 */       log.info(strSQL);
/*  50 */       rs = this.dbcon.execQuery(strSQL);
/*  51 */       if (rs.next()) {
/*  52 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/*  54 */       strSQL = " select * from powerbox where btscode ='" + strBtscode + "' limit " + start + ", " + limit;
/*  55 */       log.info(strSQL);
/*  56 */       rs = this.dbcon.execQuery(strSQL);
/*  57 */       while (rs.next()) {
/*  58 */         PowerBoxBO bo = new PowerBoxBO();
/*  59 */         bo.setId(rs.getString("id"));
/*  60 */         bo.setBtscode(rs.getString("btscode"));
/*  61 */         bo.setBtsname(rs.getString("btsname"));
/*  62 */         bo.setType(rs.getString("type"));
/*  63 */         bo.setManufacturer(rs.getString("manufacturer"));
/*  64 */         bo.setNum(rs.getString("num"));
/*  65 */         bo.setDcvoltage(rs.getString("dcvoltage"));
/*  66 */         bo.setOpentime(rs.getDate("registtime"));
/*     */ 
/*  68 */         bo.setCommtype(rs.getString("commtype"));
/*  69 */         bo.setCommcapacity(rs.getString("commcapacity"));
/*  70 */         bo.setMonmodel(rs.getString("monmodel"));
/*  71 */         bo.setMonnum(rs.getString("monnum"));
/*  72 */         bo.setMaintenance(rs.getString("maintenance"));
/*  73 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  74 */         bo.setMemo(rs.getString("memo"));
/*     */ 
/*  76 */         bo.setPboxOutI(rs.getString("pboxOutI"));
/*  77 */         bo.setPboxNum(rs.getString("pboxNum"));
/*  78 */         bo.setPboxWorkSta(rs.getString("pboxWorkSta"));
/*     */ 
/*  80 */         list.add(bo);
/*     */       }
/*  82 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/*  85 */       e.printStackTrace();
/*  86 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/*  89 */       dbConClose();
/*     */     }
/*  91 */     return bfo;
/*     */   }
/*     */ 
/*     */   public boolean savePowerBox(PowerBoxBO bo)
/*     */   {
/*  96 */     log.info("添加--电源柜---开始");
/*  97 */     boolean flag = true;
/*     */     try
/*     */     {
/* 100 */       dbConInit();
/* 101 */       StringBuffer sqlBuf = new StringBuffer();
/* 102 */       sqlBuf.append(" insert into powerbox (btscode, btsname, type, manufacturer, num, dcvoltage,");
/* 103 */       sqlBuf.append(" registtime, commtype, commcapacity, monmodel, monnum, maintenance, refreshtime,");
/* 104 */       sqlBuf.append(" memo, pboxOutI, pboxNum, pboxWorkSta) values ( ");
/* 105 */       sqlBuf.append(" '" + bo.getBtscode() + "' ,");
/* 106 */       sqlBuf.append(" '" + bo.getBtsname() + "' ,");
/* 107 */       sqlBuf.append(" '" + bo.getType() + "' ,");
/* 108 */       sqlBuf.append(" '" + bo.getManufacturer() + "' ,");
/* 109 */       sqlBuf.append(" '" + bo.getNum() + "' ,");
/* 110 */       sqlBuf.append(" '" + bo.getDcvoltage() + "' ,");
/* 111 */       sqlBuf.append(" '" + this.sdf.format(bo.getOpentime()) + "' ,");
/* 112 */       sqlBuf.append(" '" + bo.getCommtype() + "' ,");
/* 113 */       sqlBuf.append(" '" + bo.getCommcapacity() + "' ,");
/* 114 */       sqlBuf.append(" '" + bo.getMonmodel() + "' ,");
/* 115 */       sqlBuf.append(" '" + bo.getMonnum() + "' ,");
/* 116 */       sqlBuf.append(" '" + bo.getMaintenance() + "' ,");
/* 117 */       sqlBuf.append(" '" + this.sdf.format(new Date()) + "' ,");
/* 118 */       sqlBuf.append(" '" + bo.getMemo() + "' ,");
/* 119 */       sqlBuf.append(" '" + bo.getPboxOutI() + "' ,");
/* 120 */       sqlBuf.append(" '" + bo.getPboxNum() + "' ,");
/* 121 */       sqlBuf.append(" '" + bo.getPboxWorkSta() + "' )");
/* 122 */       log.info(sqlBuf.toString());
/* 123 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 127 */       flag = false;
/* 128 */       e.printStackTrace();
/* 129 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 132 */       dbConClose();
/*     */     }
/* 134 */     log.info("添加--电源柜---结束");
/* 135 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean updatePowerBox(PowerBoxBO bo)
/*     */   {
/* 140 */     log.info("修改--电源柜---开始");
/* 141 */     boolean flag = true;
/*     */     try
/*     */     {
/* 144 */       dbConInit();
/* 145 */       StringBuffer sqlBuf = new StringBuffer();
/* 146 */       sqlBuf.append(" update powerbox set ");
/*     */ 
/* 149 */       sqlBuf.append(" type = '" + bo.getType() + "' ,");
/* 150 */       sqlBuf.append(" manufacturer = '" + bo.getManufacturer() + "' ,");
/* 151 */       sqlBuf.append(" num = '" + bo.getNum() + "' ,");
/* 152 */       sqlBuf.append(" dcvoltage = '" + bo.getDcvoltage() + "' ,");
/* 153 */       sqlBuf.append(" registtime = '" + this.sdf.format(bo.getOpentime()) + "' ,");
/* 154 */       sqlBuf.append(" commtype = '" + bo.getCommtype() + "' ,");
/* 155 */       sqlBuf.append(" commcapacity = '" + bo.getCommcapacity() + "' ,");
/* 156 */       sqlBuf.append(" monmodel = '" + bo.getMonmodel() + "' ,");
/* 157 */       sqlBuf.append(" monnum = '" + bo.getMonnum() + "' ,");
/* 158 */       sqlBuf.append(" maintenance = '" + bo.getMaintenance() + "' ,");
/* 159 */       sqlBuf.append(" refreshtime = '" + this.sdf.format(new Date()) + "' ,");
/* 160 */       sqlBuf.append(" memo = '" + bo.getMemo() + "' ,");
/* 161 */       sqlBuf.append(" pboxOutI = '" + bo.getPboxOutI() + "' ,");
/* 162 */       sqlBuf.append(" pboxNum = '" + bo.getPboxNum() + "' ,");
/* 163 */       sqlBuf.append(" pboxWorkSta = '" + bo.getPboxWorkSta() + "' ");
/* 164 */       sqlBuf.append(" where id = '" + bo.getId() + "' ");
/* 165 */       log.info(sqlBuf.toString());
/* 166 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 170 */       flag = false;
/* 171 */       e.printStackTrace();
/* 172 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 175 */       dbConClose();
/*     */     }
/* 177 */     log.info("修改--电源柜---结束");
/* 178 */     return flag;
/*     */   }
/*     */ 
/*     */   public boolean deletePowerBox(String strID)
/*     */   {
/* 183 */     log.info("删除--电源柜---开始");
/* 184 */     boolean flag = true;
/*     */     try
/*     */     {
/* 187 */       dbConInit();
/* 188 */       StringBuffer sqlBuf = new StringBuffer();
/* 189 */       sqlBuf.append(" delete from powerbox   ");
/* 190 */       sqlBuf.append(" where id = '" + strID + "' ");
/* 191 */       log.info(sqlBuf.toString());
/* 192 */       this.dbcon.execUpdate(sqlBuf.toString());
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 196 */       flag = false;
/* 197 */       e.printStackTrace();
/* 198 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 201 */       dbConClose();
/*     */     }
/* 203 */     log.info("删除--电源柜---结束");
/* 204 */     return flag;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getPowerBoxByBtsName(Map condition)
/*     */   {
/* 210 */     ListContentsBFO bfo = new ListContentsBFO();
/* 211 */     int start = Integer.parseInt(condition.get("start").toString());
/* 212 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 213 */     String strBtsName = condition.get("btsName").toString();
/* 214 */     ResultSet rs = null;
/* 215 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 218 */       dbConInit();
/*     */ 
/* 220 */       Object objRegistBeginTime = condition.get("registBeginTime");
/* 221 */       Object objRegistEndTime = condition.get("registEndTime");
/*     */ 
/* 223 */       String strSQL = " select count(id) from powerbox where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' )";
/*     */ 
/* 225 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 226 */       log.info(strSQL);
/* 227 */       rs = this.dbcon.execQuery(strSQL);
/* 228 */       if (rs.next()) {
/* 229 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 231 */       strSQL = " select * from powerbox where (  btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' ) ";
/* 232 */       strSQL = FormateSQL.getFormateSQL(objRegistBeginTime, objRegistEndTime, strSQL);
/* 233 */       strSQL = strSQL + "limit " + start + ", " + limit;
/* 234 */       log.info(strSQL);
/* 235 */       rs = this.dbcon.execQuery(strSQL);
/* 236 */       while (rs.next()) {
/* 237 */         PowerBoxBO bo = new PowerBoxBO();
/* 238 */         bo.setId(rs.getString("id"));
/* 239 */         bo.setBtscode(rs.getString("btscode"));
/* 240 */         bo.setBtsname(rs.getString("btsname"));
/* 241 */         bo.setType(rs.getString("type"));
/* 242 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 243 */         bo.setNum(rs.getString("num"));
/* 244 */         bo.setDcvoltage(rs.getString("dcvoltage"));
/* 245 */         bo.setOpentime(rs.getDate("registtime"));
/*     */ 
/* 247 */         bo.setCommtype(rs.getString("commtype"));
/* 248 */         bo.setCommcapacity(rs.getString("commcapacity"));
/* 249 */         bo.setMonmodel(rs.getString("monmodel"));
/* 250 */         bo.setMonnum(rs.getString("monnum"));
/* 251 */         bo.setMaintenance(rs.getString("maintenance"));
/* 252 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 253 */         bo.setMemo(rs.getString("memo"));
/*     */ 
/* 255 */         bo.setPboxOutI(rs.getString("pboxOutI"));
/* 256 */         bo.setPboxNum(rs.getString("pboxNum"));
/* 257 */         bo.setPboxWorkSta(rs.getString("pboxWorkSta"));
/*     */ 
/* 259 */         list.add(bo);
/*     */       }
/* 261 */       bfo.setData(list.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 264 */       e.printStackTrace();
/* 265 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 268 */       dbConClose();
/*     */     }
/* 270 */     return bfo;
/*     */   }
/*     */ 
/*     */   public List export(String strBtsName, String strRegistBeginTime, String strRegistEndTime)
/*     */   {
/* 276 */     ResultSet rs = null;
/* 277 */     List list = new ArrayList();
/*     */     try
/*     */     {
/* 280 */       dbConInit();
/* 281 */       String strSQL = " select * from powerbox where ( btsname like '%" + strBtsName + "%' or manufacturer like '%" + strBtsName + "%' ) ";
/* 282 */       strSQL = FormateSQL.getFormateSQL(strRegistBeginTime, strRegistEndTime, strSQL);
/* 283 */       log.info(strSQL);
/* 284 */       rs = this.dbcon.execQuery(strSQL);
/* 285 */       while (rs.next()) {
/* 286 */         PowerBoxBO bo = new PowerBoxBO();
/* 287 */         bo.setId(rs.getString("id"));
/* 288 */         bo.setBtscode(rs.getString("btscode"));
/* 289 */         bo.setBtsname(rs.getString("btsname"));
/* 290 */         bo.setType(rs.getString("type"));
/* 291 */         bo.setManufacturer(rs.getString("manufacturer"));
/* 292 */         bo.setNum(rs.getString("num"));
/* 293 */         bo.setDcvoltage(rs.getString("dcvoltage"));
/* 294 */         bo.setOpentime(rs.getDate("registtime"));
/*     */ 
/* 296 */         bo.setCommtype(rs.getString("commtype"));
/* 297 */         bo.setCommcapacity(rs.getString("commcapacity"));
/* 298 */         bo.setMonmodel(rs.getString("monmodel"));
/* 299 */         bo.setMonnum(rs.getString("monnum"));
/* 300 */         bo.setMaintenance(rs.getString("maintenance"));
/* 301 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/* 302 */         bo.setMemo(rs.getString("memo"));
/*     */ 
/* 304 */         bo.setPboxOutI(rs.getString("pboxOutI"));
/* 305 */         bo.setPboxNum(rs.getString("pboxNum"));
/* 306 */         bo.setPboxWorkSta(rs.getString("pboxWorkSta"));
/*     */ 
/* 308 */         list.add(bo);
/*     */       }
/*     */     }
/*     */     catch (Exception e) {
/* 312 */       e.printStackTrace();
/* 313 */       log.error(e.getMessage());
/*     */     }
/*     */     finally {
/* 316 */       dbConClose();
/*     */     }
/* 318 */     return list;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.station.PowerBoxDAO
 * JD-Core Version:    0.6.2
 */